package com.yang.simple_rpc.common.protocol;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

/**
 * 响应消息封装类
 * 包含响应的状态码，返回值，相应的头部，以及异常类
 * @author : morikawaaaa
 * @date : 2022
 */
public class SimpleResponse implements Serializable {

    private static final long serialVersionUID = 49324974282362L;
    private SimpleStatus simpleStatus;
    private Map<String, String> headers = new HashMap<>();
    private Object returnValue;
    private Exception exception;
    public SimpleResponse(SimpleStatus ss){
        this.simpleStatus = ss;
    }
    public SimpleStatus getSimpleStatus() {
        return simpleStatus;
    }

    public void setSimpleStatus(SimpleStatus simpleStatus) {
        this.simpleStatus = simpleStatus;
    }

    public Map<String, String> getHeaders() {
        return headers;
    }

    public void setHeaders(Map<String, String> headers) {
        this.headers = headers;
    }

    public Object getReturnValue() {
        return returnValue;
    }

    public void setReturnValue(Object returnValue) {
        this.returnValue = returnValue;
    }

    public Exception getException() {
        return exception;
    }

    public void setException(Exception exception) {
        this.exception = exception;
    }

    public String getHeaders(String name){
        return this.headers == null ? null : this.headers.get(name);
    }

    public void setHeaders(String name, String value){
        this.headers.put(name,value);
    }
}
